<?php
/**
 * User: Allen
 * Date: 15-07-21
 * Time: 09:21
 * 评论
 */

class Comment extends PC_Controller{
	
	public function __construct(){
		parent::__construct();
		$this->load->model('comment_model');
	}
	
	//评论列表
	public function comment_list(){
		//获取总数
		$this->data['count'] = $this->comment_model->getCount();
		if($this->data['count']) {
			$this->data['data'] = $this->comment_model->getCommentlist();
		}else {
			$this->data['data'] = array();
		}
		$this->load->view('/www/comment_list.php',$this->data);
	}
	
	//删除操作
	public function del() {
		$id = $this->uri->segment(4);
		$where['id'] = $id;	
		$del_result = $this->comment_model->deleteComment($where);
		if($del_result) {
			echo "<script>alert('删除成功');window.location.replace('/www/comment/comment_list');</script>";
		}else {
			echo "<script>alert('删除失败');window.location.replace('/www/comment/comment_list');</script>";
		}
	}
}